/*
 * @Author: 杨超
 * @Date: 2021-08-10 09:52:39
 * @LastEditTime: 2021-09-27 17:28:00
 * @LastEditors: 杨超
 * @Description:
 */
import { InspectionPlanApi } from '@/api'
import CommonModel from './common'

class InspectionPlanModel extends CommonModel {
    static item = {
        // 公路名称
        road: {
            value: null
        },
        // 起始桩号
        stakeStart: {
            value: null
        },
        // 终点桩号
        stakeEnd: {
            value: null
        },
        // 项目名称
        operatId: {
            value: null
        },
        // 检查内容
        content: {
            value: null
        },
        // 判断标准
        standard: {
            value: null
        },
        locationType: {
            value: 1
        },
        direction: {
            value: null
        },
        facilityCode: {
            value: []
        },
        stakeStart1: {
            value: null
        },
        stakeStart2: {
            value: null
        },
        stakeEnd1: {
            value: null
        },
        stakeEnd2: {
            value: null
        },
        stake1: {
            value: null
        },
        stake2: {
            value: null
        }
    }
    constructor() {
        super()
        this.api = new InspectionPlanApi()
    }
    transformContentList(contentList) {
        if (!contentList) {
            return
        }
        const list = []
        contentList.forEach(ccontent => {
            const obj = {}
            for (const key in ccontent) {
                if (Object.hasOwnProperty.call(ccontent, key)) {
                    const ele = ccontent[key]
                    obj[key] = {
                        value: ele,
                        show: false
                    }
                }
            }
            obj.road = {
                value: {
                    label: obj.roadName.value,
                    value: obj.roadCode.value
                }
            }
            list.push(obj)
        })
        return list
    }
    // 获取巡查内容列表
    async getContentList(data) {
        const res = await this.api.getContentList(data)
        return res
    }
    enable(data) {
        return this.api.enable(data)
    }
}

export default InspectionPlanModel
